<template>
    <div class="wrapper">
        <Popup ref="popupRef" :title="popupTitle" :async="true" width="550px" @confirm="handleSubmit"
            @close="handleClose">
            <el-form :model="formData" :rules="formRules">
                <el-form-item label="生成数量" label-width="100px" prop="num">
                    <el-input v-model="formData.count" placeholder="请输入生成数量"></el-input>
                </el-form-item>
            </el-form>
        </Popup>
    </div>
</template>
<script lang="ts" setup>
import Popup from "@/components/popup/index.vue"
import { generaterApi } from "@/api/activity/code";
import { reactive, ref, shallowRef } from "vue";
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const popupTitle = ref("生成码号")
const emit = defineEmits(['success', 'close'])
const formData = reactive({
    count: ""
})
const formRules = reactive({
    count: [
        {
            required: true,
            message: '请输入生成数量',
            trigger: ['blur']
        }
    ],
})
const handleSubmit = async () => {
    await generaterApi(formData)
    emit('success')
    popupRef.value?.close()
}
const open = async () => {
    popupRef.value?.open()
}
const handleClose = () => {
    emit('close')
}
defineExpose({
    open,
    close
})
</script>
<style lang="scss" scoped></style>
